package com.thinksns.sociax.t4.android;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.view.WindowManager;

import com.thinksns.sociax.android.R;

/**
 * @author leiyan
 * @contact 907238552@qq.com
 * @DATE 3/31/2017
 * @Describe 应用启动第一个 Activity,为了隐藏 android 7.0 上视屏框架警告框
 */
public class InitActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);//隐藏标题栏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//隐藏状态栏
        setContentView(R.layout.activity_init);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                try {
                    startApp();
                } catch (Exception e) {
                    e.printStackTrace();
                    startApp();
                }
            }
        }, 50);

    }

    /**
     * 真正的启动应用第一个 Activity
     */
    private void startApp() {
        startActivity(new Intent(InitActivity.this, ThinksnsActivity.class));
        if (!isFinishing()) {
            finish();
        }
    }
}
